﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="email_wdyj_edit.aspx.cs" Inherits="Ccit.OA.Email.email_wdyj_edit" %>

<%@ Register assembly="FreeTextBox" namespace="FreeTextBoxControls" tagprefix="FTB" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>个人签名</title>
   <script language="javascript" src="../script/jquery.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
    <script language="javascript" src="../script/jsonlib.js" type="text/javascript" ></script>
    <script language="javascript" src="../script/StringClass_Ext.js" type="text/javascript" ></script>
    <script language="javascript">
         function doSave()
         {
            if(CheckVal() == true)
            {
                var jsonStr = jsonObj();
                PageMethods.Save(jsonStr,ClientCallBack); 
            }
         }
         
         function doDel()
         {   
            if($get("hidId").value != "")
            {
                 if(confirm("确定删除已选定的邮件?"))
                 {

                        var jsonStr = jsonObj();
                        PageMethods.Del(jsonStr,ClientCallBack);        
                 }
             }
             else { 
                    alert("请先选择要删除的邮件!");
                    return false;
                }
             return true;
         }
         
         function CheckVal()
         {
            if($get("txtTitle").value == "")
            {
                alert("标题不允许为空!");
                return false;
            }
            if($get("txtContent").value == "")
            {
                alert("请填写签名内容!");
                return false;
            }
            return true;
         }
         
                         
        function jsonObj() //返回序列化后的字符串
        {
           var  sdefault = document.getElementById("cbMR").value;
           if(document.getElementById("cbMR").checked == true)
           {
                sdefault = "1";
           }
         var MsSigna ={};
                MsSigna.Id = $get("hidId").value;
                MsSigna.userId = $get("hidUserId").value;
                MsSigna.title = $get("txtTitle").value;
                MsSigna.content = $get("txtContent").value;
                MsSigna.defaultlogo = sdefault;
                MsSigna.agencId =$get("hidJG").value;
                MsSigna.deptId = $get("hidYGBM").value;
                MsSigna.jobId = $get("hidYGZW").value;
                MsSigna.levelId = $get("hidYGJB").value;
                MsSigna.cjuserId = $get("hidUserId").value;
                MsSigna.cjdatetime =  $get("hidTime").value;
                var jsonStr = JSON.stringify(MsSigna,function(key,value){return value;});  
                return jsonStr;
        }
        
        
         function ClientCallBack(vResult) {
            eval("var resultObj=" + vResult);
            var operType = resultObj.operType;
            var resultSign = resultObj.resultSign;
            var resultSignId = resultObj.resultSignId;
            switch (operType) {
                case "Del": 
                    if (resultSign == "0") {
                        alert("删除失败!");
                    }
                    else {
                            parent.frames[0].document.getElementById("_hidDelSignId").value = resultObj.resultSignId; 
                            parent.frames[0].document.all.btnDelTrigger.click(); 
                            parent.frames[1].location.href = "email_wdyj_edit.aspx"
                    }
                    break;
                case "insert":
                     if (resultSign == "0") {
                        alert("保存失败!");
                    }
                    else {
                        
                          //实例化MsEmailSigna消息对象
                        var MsEmailSigna = {};
                        MsEmailSigna.Id= resultObj.resultSignId;        
                        MsEmailSigna.Title = resultObj.resultName;       //签名标题                      
                       
                        var jsonExpr=JSON.stringify(MsEmailSigna,function(key,value){return value;});
                        parent.frames[0].document.getElementById("_hidNewSignObject").value = jsonExpr;  //新增 
                        parent.frames[0].document.getElementById("_hidAddNewSign").value = "0";  //新增 
                        parent.frames[0].document.all.btnTrigger.click(); 
                        parent.frames[1].location.href = "email_wdyj_edit.aspx"
                        
                        alert("保存成功!");
                    }
                break;
                case "update":
                     if (resultSign == "0") {
                            alert("更新失败!");
                        }
                        else {
                           //实例化MsEmailSigna消息对象
                        var MsEmailSigna = {};
                        MsEmailSigna.Id= resultObj.resultSignId;        
                        MsEmailSigna.Title = resultObj.resultName;       //签名标题                      
                       
                        var jsonExpr=JSON.stringify(MsEmailSigna,function(key,value){return value;});
                         parent.frames[0].document.getElementById("_hidNewSignObject").value = jsonExpr;  //更新
                        parent.frames[0].document.getElementById("_hidAddNewSign").value = "1";  //更新
                        parent.frames[0].document.all.btnTrigger.click(); 
                        
                        alert("更新成功!");
                     }
                break;
                }
              }
    </script>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
            <input  type="hidden" id="hidId" runat="server" />
            <input  type="hidden" id="hidUserId" runat="server" />
    		<input type="hidden" id="hidYGJB" runat="server" />
			<input type="hidden" id="hidYGBM" runat="server" />
			<input type="hidden" id="hidYGZW" runat="server" />
			<input type="hidden" id="hidJG" runat="server" />
			<input type="hidden" id="hidTime" runat="server" />
             <table class="tableborder" cellSpacing="0" cellPadding="0" width="98%" align="center">
                <tr HEIGHT="60">
                    <td class="pformleft"  align="right" width="7%">标题</td>
                    <td   class="pformright" align="left" width="92%"><asp:TextBox CssClass="input"  ID="txtTitle" Width="98%" runat="server"></asp:TextBox></td>
                </tr>
                <tr >
                    <td  class="pformleft" align="right"  valign="top" width="7%">内容</td>
                    <td class="pformright" align="left" width="92%">
                    <FTB:FREETEXTBOX  id="txtContent"  runat="server" Width="103%" height="300px" tabIndex="2" FontFacesMenuPath="../css/">
					</FTB:FREETEXTBOX>
                    </td>
                </tr>
                <tr>
                    <td align="left" class="pformleft" colspan="2">&nbsp;&nbsp;&nbsp;<input runat="server" type="checkbox" id="cbMR" value="0" />设置为默认签名</td>
                </tr>
               <tr align="center">
                    <td class="pformstrip" colspan="2"  align="center" valign="middle"><input type="button" class="button" value="保 存" onclick="doSave();"/> 
                    <input class="button" type="button" id="btdel" value="删 除" onclick="return doDel()" />
                    </td>
                </tr>
             </table>
   </ccit:ActionForm>
</body>
</html>
